package test05.demo2;

public class MyRunnable implements Runnable {

    /**
     * 帐号
     */
    private Account account;

    /**
     * 取钱用户
     */
    private String user;

    /**
     * 取钱金额
     */
    private double money;

    /**
     * 锁对象 - 唯一性
     */
    private static final Object LOCK = new Object();

    public MyRunnable() {
    }

    public MyRunnable(Account account, String user, double money) {
        this.account = account;
        this.user = user;
        this.money = money;
    }


    @Override
    public void run() {
        synchronized (LOCK) {
            account.getMoney(user, money);
        }
    }

    // public void run() {
    //     synchronized (this) {
    //         account.getMoney(user, money);
    //     }
    // }
}